package com.tang.excel.oci.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.tang.excel.oci.domain.WarmWater;
import com.tang.excel.oci.mapper.WarmGullyWaterMapper;
import com.tang.excel.oci.mapper.WarmWaterMapper;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Tang
 * @classname WarmWaterListener
 * @description [ 温水 ]
 * @date 2021/5/20 15:30
 */
public class WarmWaterListener extends AnalysisEventListener<WarmWater> {

    WarmGullyWaterMapper warmGullyWaterMapper;

    List<WarmWater> list = new ArrayList<>(10);

    public WarmWaterListener(WarmGullyWaterMapper warmGullyWaterMapper) {
        this.warmGullyWaterMapper = warmGullyWaterMapper;
    }

    @Override
    public void invoke(WarmWater warmWater, AnalysisContext analysisContext) {
        warmWater.setCodValue(Double.valueOf(warmWater.getCod().replace("(mg/L)","")));
        warmWater.setName("COD");
        list.add(warmWater);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        warmGullyWaterMapper.batchInsert1(list);
    }

}